﻿
namespace Marmat.Forms
{
    internal partial class LookUpEditForm : PopupControl
    {
        public LookUpEditForm()
        {
            InitializeComponent();
            GridView1.Name = "GridView1";
        }

        private void GridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (this.OwnerEdit is object)
                {
                    LookUpEdit BLookUpEdit = (LookUpEdit)this.OwnerEdit.Parent;
                    var dr = this.GridView1.GetDataRow(e.RowHandle);
                    BLookUpEdit.SelectedItem = dr;
                    if (dr is object)
                    {
                        this.Value = dr[((LookUpEdit)this.OwnerEdit.Parent).ValueMember];
                    }
                }

                this.CloseDropDown();
            }
        }
    }
}